<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" href="../../layui/css/layui.css" media="all">
</head>
<body>
	<form id="updateMess" class="layui-form" action="../../drugManager/addOrUpdates.action" onsubmit="return verifys()" method="post" >
		  <input type="hidden" name="manId" id="manId" >
		  <input type="hidden" id="filId" name="filId">
		  <input type="hidden" id="roleIds" name="roleIds">
		  <div class="layui-form-item">
		        <label class="layui-form-label">用户头像</label>
		        <div class="layui-input-block">
		            <button type="button" class="layui-btn" id="uploadTwo">上传图片</button>
		            <input type="hidden" id="img_urlTwo" name="manRemark" value=""/>
		            <div class="layui-upload-list">
		                <img class="demoTow" width="100px" height="80px" id="demoTow"/>
		                <p id="demoTextTwo"></p>
		            </div>
		        </div>
		  </div>
		  <div class="layui-form-item">
		    <label class="layui-form-label">用户名</label>
		    <div class="layui-input-block">
		      <input type="text" name="manUser" id="manUser" lay-verify="required" disabled autocomplete="off" class="layui-input layui-disabled" style="width:280px;">
		    </div>
		  </div>
		  <div class="layui-form-item layui-form-text">
		    <label class="layui-form-label">密码</label>
		    <div class="layui-input-block">
		      <input type="password" name="manPwd" id="manPwd" lay-verify="required" placeholder="请输入密码" autocomplete="off" class="layui-input" style="width:280px;">
		    </div>
		  </div>
		  <div class="layui-form-item">
		    <label class="layui-form-label">手机号</label>
		    <div class="layui-input-block">
		      <input type="text" name="manPhone" id="manPhone" lay-verify="required" placeholder="请输入手机号" autocomplete="off" class="layui-input" style="width:280px;">
		    </div>
		  </div>
		  <div class="layui-form-item">
		    <label class="layui-form-label">身份证</label>
		    <div class="layui-input-block">
		      <input type="text" name="manCardid" id="manCardid" lay-verify="required" placeholder="请输入身份证" autocomplete="off" class="layui-input" style="width:280px;">
		    </div>
		  </div>
		  
		  <div class="layui-form-item">
		    <div class="layui-input-block">
		      <input type="button" class="layui-btn" lay-submit="" lay-filter="demo" value="提交">
		    </div>
		  </div>
	 </form>
</body>
<script src="../../js/jquery-3.1.1.min.js" charset="utf-8"></script>
<script src="../../layui/layui.js" charset="utf-8"></script>
<script src="../../js/base.js"></script>
<script type="text/javascript">
var path=getRootPath();
layui.use(['form','laydate', 'laypage', 'layer', 'table', 'upload', 'element','tree'], function() {
	var form = layui.form
	  ,laydate = layui.laydate //日期
	  ,laypage = layui.laypage //分页
	  ,layer = layui.layer //弹层
	  ,table = layui.table //表格
	  ,upload = layui.upload //上传
	  ,element = layui.element; //元素操作	
	//上传文件
	var uploadInsts = upload.render({
	    elem: '#uploadTwo' //绑定元素
	    ,url: path+'upload/uploadFile.action' //上传接口
	    ,before: function(obj){
	        //预读本地文件示例，不支持ie8
	        obj.preview(function(index, file, result){
	      	  
	            $('#demoTow').attr('src', result); //图片链接（base64）
	        });
	    }
	    ,done: function(res){
	        //如果上传失败
	        if(res.code > 0){
	            return layer.msg('上传失败');
	        }
	        //上传成功
	        document.getElementById("img_urlTwo").value = res.url;

	    }
	    ,error: function(){
	        //演示失败状态，并实现重传
	        var demoText = $('#demoTextTwo');
	        demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-mini demo-reload">重试</a>');
	        demoText.find('.demo-reload').on('click', function(){
	      	  uploadInsts.upload();
	        });
	    }
	});
	//监听提交
	form.on('submit(demo)', function(data){
		  
		var data = $("#updateMess").serialize();
		var url = "../../drugManager/addOrUpdates.action";
			
		$.post(url, data, function(data){
			
			layer.msg("修改成功", {
				  icon: 1,
				  time: 1000 //1秒关闭（如果不配置，默认是3秒）
				}, function(){
				  parent.location.reload();
			});
		});
	});
});

function load(){
	
	$.ajax({
		asyn : true,
		type : "POST",
		url : "../../drugManager/findModByManager.action",
		data:null,
		success : function(data) {
			
			$("#manId").val(data.manId);
			$("#filId").val(data.filId);
			$("#manUser").val(data.manUser);
			$("#manPwd").val(data.manPwd);
			$("#manPhone").val(data.manPhone);
			$("#manCardid").val(data.manCardid);
			$("#img_urlTwo").val(data.manRemark);
			$("#demoTow").attr("src",path+data.manRemark); 
			
			
			layui.form.render();
		},
		error : function(fh) {
		}
	});
}
load();
</script>
</html>